Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: raylib5 #180

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

WIP: raylib5 #180

wants to merge 7 commits into from

Conversation

konsumer
Copy link
Collaborator

Raylib5 was released. This branch documents the effort to upgrade.

Currently this fails to build. These are missing:

  • GenImageGradientV
  • GenImageGradientH
  • LoadModelAnimations
  • DrawLineBezierQuad
  • DrawLineBezierCubic

@konsumer konsumer changed the title WIP raylib5 WIP: raylib5 Nov 18, 2023
@konsumer
Copy link
Collaborator Author

Updating @raylib/api to latest seems to fix errors with actual raylib, but then I see other errors with raygui. We may have to split these or work on getting raygui working.

@konsumer
Copy link
Collaborator Author

konsumer commented Nov 11, 2024

On mac M1 (Sonoma 14.6.1 (23G93)) I think issue is something in node-raylib.cc. It's a bit hard to tell because it buries the build-error (it seems to select ninja, and I always have that prob with ninja, since I am dyslexic and it strips colors) but I searched for error, and I see these 2:

/Users/konsumer/Desktop/node-raylib/src/generated/node-raylib.cc:319:6: error: non-constant-expression cannot be narrowed from type 'uintptr_t' (aka 'unsigned long') to 'char' in initializer list [-Wc++11-narrowing]
  319 |      pointerFromValue(info, index + 4)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/konsumer/Desktop/node-raylib/src/generated/node-raylib.cc:319:6: note: insert an explicit cast to silence this issue
  319 |      pointerFromValue(info, index + 4)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |      static_cast<char>(               )
/Users/konsumer/Desktop/node-raylib/src/generated/node-raylib.cc:395:6: error: non-constant-expression cannot be narrowed from type 'uintptr_t' (aka 'unsigned long') to 'int' in initializer list [-Wc++11-narrowing]
  395 |      pointerFromValue(info, index + 2)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/konsumer/Desktop/node-raylib/src/generated/node-raylib.cc:395:6: note: insert an explicit cast to silence this issue
  395 |      pointerFromValue(info, index + 2)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |      static_cast<int>(                )

looks like uintptr_t (64 bit) is being crammed into 8bit char var.

In both cases, it appears to be usage of pointerFromValue:

inline ModelAnimation ModelAnimationFromValue(const Napi::CallbackInfo& info, int index) {
  return {
     intFromValue(info, index + 0),
     intFromValue(info, index + 1),
     (BoneInfo *) pointerFromValue(info, index + 2),
     (Transform **) pointerFromValue(info, index + 3),

     // HERE
     pointerFromValue(info, index + 4)
  };
}

inline AutomationEvent AutomationEventFromValue(const Napi::CallbackInfo& info, int index) {
  return {
     unsignedintFromValue(info, index + 0),
     unsignedintFromValue(info, index + 1),
     
     // HERE
     pointerFromValue(info, index + 2)
  };
}

In other uses of these, they have type-prefixes (to set what kind of pointer it is) so that might be the prob.

These are the 2 type-conversions:

// ModelAnimation
typedef struct ModelAnimation {
    int boneCount;          // Number of bones
    int frameCount;         // Number of animation frames
    BoneInfo *bones;        // Bones information (skeleton)
    Transform **framePoses; // Poses array by frame
    char name[32];          // Animation name
} ModelAnimation;

// Automation event
typedef struct AutomationEvent {
    unsigned int frame;             // Event frame
    unsigned int type;              // Event type (AutomationEventType)
    int params[4];                  // Event parameters (if required)
} AutomationEvent;

I tried to manually fix on first one, to try to match it to other calls of pointerFromValue:

inline ModelAnimation ModelAnimationFromValue(const Napi::CallbackInfo& info, int index) {
  return {
     intFromValue(info, index + 0),
     intFromValue(info, index + 1),
     (BoneInfo *) pointerFromValue(info, index + 2),
     (Transform **) pointerFromValue(info, index + 3),
     (char*)pointerFromValue(info, index + 4)
  };
}

which caused another error:

/Users/konsumer/Desktop/node-raylib/src/generated/node-raylib.cc:319:6: error: cannot initialize an array element of type 'char' with an rvalue of type 'char *'
  319 |      (char*)pointerFromValue(info, index + 4)
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

so I am not sure how to resolve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants